<%@page contentType="text/html;charset=utf-8" %>
<%@taglib prefix="s" uri="/struts-tags" %> 
<s:if test="pageTag<0">
<script type="text/javascript">
function client_qy_u_change_province()
{
    var url = "qy/cpuser/p1/changeprovince.do";
    var content = "province=" + dijit.byId("province").get('value');
    var objectid = "qy_region";
    sendXMLHttpRequest(url, content, objectid); 
};

function client_qy_u_change_channel()
{
    var url = "qy/cpuser/p1/changechannel.do";
    var content = "channelId=" + dijit.byId("channel").get('value');
    var objectid = "qy_projects";
    sendXMLHttpRequest(url, content, objectid); 
};

function client_qy_u_cpuser_data()
{
	var url      = "qy/cpuser/p1/data.do";
    var content  = "pageTag=1"
                 + "&dimension=" + get_query_dimension(2)
                 + "&date1=" + document.getElementById("date1").value
                 + "&date2=" + document.getElementById("date2").value
                 + "&channelId=" + dijit.byId("channel").get('value')
                 + "&projectId=-1"
                 + "&province=ALL"
                 + "&region=ALL";
    var objectid = "qy_data";
    sendXMLHttpRequest(url, content, objectid);
};

</script>
 <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="5"></td>
    <td>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="5"></td>
      </tr>
      <tr>
        <td height="25" class="t1"><img src="images/small0.gif" width="14" height="12" /> 您现在的位置&gt;&gt;CP用户统计</td>
      </tr>
    </table>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td colspan="6">
        <table width="100%"  border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><img src="images/table_top_left.jpg" width="20" height="15" /></td>
            <td><img src="images/table_top_bg.jpg" width="770" height="15"/></td>
            <td align="right"><img src="images/table_top_right.jpg" width="20" height="15" /></td>
          </tr>
        </table>
        </td>
      </tr>
      <tr>
        <td height="25" colspan="6" class="table_blue">　<strong><img src="images/dot.jpg" width="13" height="9">统计条件</strong></td>
      </tr>    
      <tr>
      <td height="25" class="table_w1" align="center" width="10%">开始日期：</td>
        <td class="table_w2" width="20%">&nbsp;
          <input type="text" id="date1" dojoType="dijit.form.DateTextBox" style="width:135px;"
             value="<s:property value="date1" />" constraints="{datePattern:'yyyy-MM-dd'}" />   
        </td>
        <td class="table_w2" align="center" width="10%">结束日期：</td>
        <td class="table_w2" width="20%">&nbsp;
          <input type="text" id="date2" dojoType="dijit.form.DateTextBox" style="width:135px;"
             value="<s:property value="date2" />" constraints="{datePattern:'yyyy-MM-dd'}" />      
        </td>
         <td class="table_w2" rowspan="2" colspan="2" align="left">
         &nbsp;&nbsp;
          <input id="dimension[0]" dojoType="dijit.form.CheckBox" value="day" checked ><label for="dimension[0]">日期</label>
         <input id="dimension[1]" dojoType="dijit.form.CheckBox" value="channel"><label for="dimension[1]">渠道</label>
          &nbsp;&nbsp;
          <button id="btn1" dojoType="dijit.form.Button" 
             onClick="client_qy_u_cpuser_data();" iconClass="plusIcon">查询</button></td>
      </tr>
      <tr>
         <td class="table_w1" align="center" width="10%">渠道信息：</td>
         <td class="table_w2" height="<s:property value="(channels.size()>1?2:1)*25"/>" width="17%"><div>&nbsp;
             <select id="channel" dojoType="dijit.form.FilteringSelect" style="width:135px;">
               <option value="-1">全部</option>
               <s:iterator value="channels" status="stat">
               <option value="<s:property value="id" />" ><s:property value="name" /></option>
               </s:iterator>
             </select></div>
         </td>
      </tr> 
      <tr> 
        <td colspan="6" background="images/table_bom_bg.jpg">
          <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><img src="images/table_bom_left.jpg" width="20" height="15"></td>
            <td></td>
            <td align="right"><img src="images/table_bom_right.jpg" width="20" height="15"></td>
          </tr>
          </table>
        </td>
      </tr>
    </table>  
  </td>
  <td width="5"></td>
  </tr>
  </table>
  <div id="qy_data"></div> 
</s:if>
<s:else>
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="5"></td>
    <td>
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td colspan="<s:property value="%{getQueryDimensionCount(dimension)+2}"/>">
       <table width="100%"  border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><img src="images/table_top_left.jpg" width="20" height="15" /></td>
            <td><img src="images/table_top_bg.jpg" width="770" height="15"/></td>
            <td align="right"><img src="images/table_top_right.jpg" width="20" height="15" /></td>
          </tr>
        </table>
      </td>
    </tr>
    <tr>
      <td height="25" colspan="<s:property value="%{getQueryDimensionCount(dimension)+2}"/>" 
        class="table_blue">　<strong><img src="images/dot.jpg" width="13" height="9">查询结果</strong></td>
    </tr> 
    <s:if test="hasActionErrors()"> 
    <tr>
      <td class="table_w1" colspan="<s:property value="%{getQueryDimensionCount(dimension)+2}"/>" align="center">
        <strong><font color="red"><s:actionerror /></font></strong>
      </td>
    </tr>
    </s:if>
    <tr>
    <td>
    <table id="sort_table" width="100%" border="0" cellspacing="0" cellpadding="0"
           style="word-break:break-all;">
    <tr>
      <td align="center" class="table_g1" width="5%">序号</td>
      <s:if test="%{checkQueryDimension(dimension,'day')}">
      <td align="center" class="table_g2" width="10%">日期</td></s:if>
      <s:if test="%{checkQueryDimension(dimension,'hour')}">
      <td align="center" class="table_g2" width="5%">小时</td></s:if>
      <s:if test="%{checkQueryDimension(dimension,'minute')}">
      <td align="center" class="table_g2" width="5%">分钟</td></s:if>
      <s:if test="%{checkQueryDimension(dimension,'channel')}">
      <td align="center" class="table_g2" width="10%">渠道</td></s:if>
      <s:if test="%{checkQueryDimension(dimension,'project')}">
      <td align="center" class="table_g2" width="15%">项目</td></s:if>
      <s:if test="%{checkQueryDimension(dimension,'province')}">
      <td align="center" class="table_g2" width="5%">省份</td></s:if>
      <s:if test="%{checkQueryDimension(dimension,'region')}">
      <td align="center" class="table_g2" width="5%">地区</td></s:if>
      <td align="center" class="table_g2" width="7%">新增数</td>
    </tr>
    <tbody id="sort_body">
    <s:if test="datas.size()>0" >
    <s:set var="totalcount" value="0" />
    <s:set var="totalnewcount" value="0" />
    <s:iterator value="datas" status="stat1" >    
    <tr onmouseover="this.style.background='#c0c0c0';" 
        onmouseout="this.style.background='#ffffff';" >
      <td class="table_w1" align="center"><s:property value="#stat1.index+1" /></td>
      <s:if test="%{checkQueryDimension(dimension,'day')}">
      <td class="table_w2" align="center"><s:property value="day" /></td></s:if>
      <s:if test="%{checkQueryDimension(dimension,'hour')}">
      <td class="table_w2" align="center"><s:property value="hour" /></td></s:if>
      <s:if test="%{checkQueryDimension(dimension,'minute')}">
      <td class="table_w2" align="center"><s:property value="(minute*10)+'~'+((minute+1)*10-1)" /></td></s:if>
      <s:if test="%{checkQueryDimension(dimension,'channel')}">
      <td class="table_w2" align="center">
      <s:iterator value="channels" status="stat3">
               <s:if test="channel.equals(id)"><s:property value="name"/></s:if>
      </s:iterator>
      </td></s:if>
      <s:if test="%{checkQueryDimension(dimension,'project')}">
      <td class="table_w2" align="center">
     	<s:iterator value="projects" status="stat4">
               <s:if test="project.equals(id)"><s:property value="name"/></s:if>
               </s:iterator>
      </td></s:if>
      <s:if test="%{checkQueryDimension(dimension,'province')}">
      <td class="table_w2" align="center"><s:property value="province" /></td></s:if>
      <s:if test="%{checkQueryDimension(dimension,'region')}">
      <td class="table_w2" align="center"><s:property value="region" /></td></s:if>
      <td class="table_w2" align="center"><s:property value="newcount" /></td>
      <s:set var="totalcount" value="#totalcount+count" />
      <s:set var="totalnewcount" value="#totalnewcount+newcount" />
    </tr>
    </s:iterator>
    <tr bgcolor="#c0c0f0">
      <td class="table_w1" align="center" colspan="<s:property value="%{getQueryDimensionCount(dimension)+1}"/>">合计</td>
      <td class="table_w2" align="center"><s:property value="#totalnewcount" /></td>
    </tr>
    </s:if>
    <s:else>    
    <tr>
      <td class="table_w1" align="center" colspan="<s:property value="%{getQueryDimensionCount(dimension)+2}"/>">无</td>
    </tr>
    </s:else>
    </tbody>
    </table>
    </td>
    </tr>
    <tr> 
      <td colspan="<s:property value="%{getQueryDimensionCount(dimension)+2}"/>" background="images/table_bom_bg.jpg">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td><img src="images/table_bom_left.jpg" width="20" height="15"></td>
          <td></td>
          <td align="right"><img src="images/table_bom_right.jpg" width="20" height="15"></td>
        </tr>
        </table>
      </td>
    </tr>
  </table>  
  </td>
  <td width="5"></td>
  </tr>
  </table>
</s:else>